package JavaSE.CODE.ClassInCommonUse;

import java.util.Arrays;

public class Sys {
    public static void main(String[] args) {
        //arraycopy方法
        int[] arr = {23,45,14,25,67,88,2,3};
        int[] dest = new int[8];
        System.arraycopy(arr,0,dest,0,arr.length);
        //src: 源数组 srcPos: 从源数组的哪个位置开始 dest: 目标数组 destPos: 从目标数组的哪个位置 length: 复制多长
        for (int i : dest) {
//            System.out.println(i);
        }
//      Arrays.copyOf()内部是用System.arraycopy实现的
//      arraycopy 是 native方法，即用C++实现的，效率更高

        //获取系统当前的时间，返回毫秒
        System.out.println(System.currentTimeMillis());
        //获取运行时间
        long start = System.currentTimeMillis();
        {
            for (int i = 0; i < 999999; i++) {
                for (int j = 0; j < 99; j++) {
                    for (int k = 0; k < 9; k++) {

                    }
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start));

        new Student("a");
        new Student("b");
        new Student("b");
        new Student("c");
        //建议启动垃圾回收器回收垃圾，具体实操要看系统系统
        System.gc();

        //退出jvm，即结束程序
        System.exit(0);

        System.out.println(1);//不会被执行

    }
}

class Student{

    String name;

    public Student(String name){
        this.name = name;
    }

    protected void finalize() throws Throwable {
        System.out.println("name: " + this.name);
    }
}